> ## Documentation Index
> Fetch the complete documentation index at: https://sequence-0fb8d9e6-api_docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ethers v6 Migration Guide

> Support for ethers v6 and migration guides for moving code from ethers v5 to v6

The @0xsequence package v2.0 now requires at a minimum the Ethers version `ethers`.

<Note>
  If you are unable to upgrade to ethers v6, then you can use v1.10.5 of @0xsequence or 3.0.0 of @0xsequence/kit.
</Note>

If you've been developing with `ethers@^5.0.0` in the past, outlined below are the common ways using Ethers with Sequence will change for you:

## Static and Default RPC Provider

To use ethers to connect and make [RPC](https://en.wikipedia.org/wiki/Remote_procedure_call) calls to a blockchain node in order to query information, doing so in a static or default way both have differences:

```typescript provider.ts theme={null}
// v5
const provider = new ethers.providers.StaticJsonRpcProvider(chainConfig.rpcUrl);

// v6: If you know the network ahead of time and wish
// to avoid even a single eth_chainId call
const provider = new ethers.JsonRpcProvider(chainConfig.rpcUrl, undefined, {
	staticNetwork: new ethers.Network('<CHAIN_HANDLE>', <CHAIN_ID>)
});

// v6: If you want the network automatically detected,
// this will query eth_chainId only once
const provider = new ethers.JsonRpcProvider(chainConfig.rpcUrl, undefined, {
  staticNetwork: true
});
```

## Big Number Support

If you're using big numbers to generate randomly spaced token ID's, nonces, or some other application of large string based numbers, ethers now supports built-in ES2020 BigInt offered by modern JavaScript environments.

```typescript bigNumber.ts theme={null}
// v5
value = BigNumber.from("1000")

// v6 
// Notice the suffix n (using literal notation).
value = 1000n

// v6 
// Using the BigInt function for strings
value = BigInt("1000")
```

## Removal of Ethers Utilities

Using Ethers you will notice there is no longer a `ethers.utils` path. Therefore, all paths should be updated without the `utils`:

```typescript contract_parameters.ts theme={null}
// v5
const amountBigNumber = ethers.utils.parseUnits(String(price), 18); // currency price based on correct decimals for token contract
const erc20Interface = new ethers.utils.Interface([
          "function approve(address spender, uint256 amount) external returns (bool)"
        ]);
        
// v6
const amountBigNumber = ethers.parseUnits(String(price), 18); // currency price based on correct decimals for token contract
const erc20Interface = new ethers.Interface([
          "function approve(address spender, uint256 amount) external returns (bool)"
        ]);
```

## Utility Hash Value Packing

If you're using ethers utilities to perform signature creation then using `ecrecover` on-chain, signature creation is now slightly different:

```typescript signature_creation.ts theme={null}
// v5
const hash = ethers.utils.solidityKeccak256(['uint', 'uint'], [value1, blockNumber])
const arr = ethers.utils.arrayify(hash)
const signature = await wallet.signMessage(arr)

// v6
const hash = ethers.solidityPackedKeccak256(['uint', 'uint'], [value1, blockNumber])
const arr = ethers.getBytes(hash)
const signature = await wallet.signMessage(arr)
```

<Tip>
  For complete information on the differences of Ethers `v5` to `v6` you can read more [here](https://docs.ethers.org/v6/migrating/) in the official docs.
</Tip>
